package top.yueyazhui.storage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.yueyazhui.common.bean.Response;
import top.yueyazhui.storage.service.StorageService;

@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    StorageService storageService;

    @PostMapping("/deduct")
    public Response deductStorage(@RequestParam("commodityCode") String commodityCode, @RequestParam("count") Integer count) {
        if (storageService.deductStorage(commodityCode, count)) {
            return Response.success("扣库存成功");
        }
        return Response.error("扣库存失败");
    }
}
